package cn.b.sky.mes.pp.service.impl;

import java.util.List;

import javax.annotation.Resource;

import cn.b.sky.mes.pp.dao.OperationTaskConfirmDao;
import cn.b.sky.mes.pp.model.OperationTaskConfirm;
import cn.b.sky.mes.pp.model.condition.OperationTaskConfirmCondition;
import cn.b.sky.mes.pp.service.OperationTaskConfirmService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service("operationTaskConfirmService")
public class OperationTaskConfirmServiceImpl implements
        OperationTaskConfirmService {

	@Resource
    OperationTaskConfirmDao operationTaskConfirmDao;

	@Override
	public List<OperationTaskConfirm> getOperationTaskConfirmByCondition(
			OperationTaskConfirmCondition condition) {
		if (condition == null) {
			return null;
		}
		return operationTaskConfirmDao
				.getOperationTaskConfirmByCondition(condition);
	}

	@Override
	public int getOperationTaskConfirmCountByCondition(
			OperationTaskConfirmCondition condition) {
		if (condition == null) {
			return 0;
		}
		return operationTaskConfirmDao
				.getOperationTaskConfirmCountByCondition(condition);
	}

	@Override
	public boolean whetheroperationTaskConfirm(String siteCode,
			String operationTaskNum) {
		if (StringUtils.isBlank(operationTaskNum)) {
			return true;
		}
		OperationTaskConfirmCondition condition = new OperationTaskConfirmCondition();
		condition.setSiteCode(siteCode);
		condition.setOperationTaskNum(operationTaskNum);
		return operationTaskConfirmDao
				.getOperationTaskConfirmCountByCondition(condition) != 0;
	}

	@Override
	public List<OperationTaskConfirm> getConfirmRecordSelectByCondition(
			OperationTaskConfirmCondition condition) {
		if (condition == null) {
			return null;
		}
		return operationTaskConfirmDao
				.getConfirmRecordSelectByCondition(condition);
	}

	@Override
	public int getConfirmRecordSelectCountByCondition(
			OperationTaskConfirmCondition condition) {
		if (condition == null) {
			return 0;
		}
		return operationTaskConfirmDao
				.getConfirmRecordSelectCountByCondition(condition);
	}

	@Override
	public List<OperationTaskConfirm> selectAllConfirmRecordByCondition(
			OperationTaskConfirmCondition condition) {
		if (StringUtils.isBlank(condition.getOrderField())) {
			condition.setOrderField("CreateDateTime");
		}
		return operationTaskConfirmDao
				.selectAllConfirmRecordByCondition(condition);
	}
}
